using Habanero.BO;
using Habanero.BO.ClassDefinition;
using Habanero.BO.Loaders;
using Habanero.UI.Base;
using Habanero.UI.Win;
using NUnit.Framework;
using UseCaseManager.BO;
using UseCaseManager.Test.BO;
using UseCaseManager.UI;

namespace UseCaseManager.Test.UI
{
    /// <summary>
    /// This is a test class for testing the <see cref="DropsGridControl"/>
    /// </summary>
    [TestFixture]
    public class TestDropsGridControl
    {
        [TestFixtureSetUp]
        public void SetupTestFixture()
        {
            //Executes once for all tests in this fixture
            //BORegistry.DataAccessor = new DataAccessorDB();
            
            ClassDef.ClassDefs.Clear();
            ClassDef.LoadClassDefs(new XmlClassDefsLoader(BOBroker.GetClassDefsXml(), new DtdLoader()));
        }
        [SetUp]
        public void TestSetup()
        {
            //Test Setup Runs prior to each test in this fixture executing.
            BORegistry.DataAccessor = new DataAccessorInMemory();
            TestUtils.ClearAllTables();
            BusinessObjectManager.Instance.ClearLoadedObjects();
            TestUtils.WaitForGC();
            GlobalUIRegistry.ControlFactory = new ControlFactoryWin(); 
        }

        [Test]
        public void Test_CreateDropsGridControl()
        {
            //---------------Set up test pack-------------------
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            DropsGridControl dropPlanner = new DropsGridControl();
            //---------------Test Result -----------------------
            Assert.IsNotNull(dropPlanner);
            Assert.IsNotNull(dropPlanner.GridSelector);
            Assert.IsInstanceOfType(typeof(ReadOnlyGridControlWin), dropPlanner.GridSelector);
            ReadOnlyGridControlWin gridControl =  (ReadOnlyGridControlWin) dropPlanner.GridSelector;
        }
    }
}